Skip to content

Dev#84

Merged
dogesman098 merged 25 commits intomainfrom
dev
Aug 26, 2025
Merged

Dev#84
dogesman098 merged 25 commits intomainfrom
dev

Conversation

@Jackson57279
Copy link
Owner

@Jackson57279 Jackson57279 commented Aug 26, 2025

Summary by CodeRabbit

  • New Features
    • Upgrade action in the chat interface now routes directly to the pricing page for a smoother flow.
  • Chores
    • Internal authentication logic reviewed with no user-facing impact.
  • Style
    • Minor formatting adjustments made; no change to functionality.

Jackson57279 and others added 24 commits August 22, 2025 20:52
…d rate limiting

- Add clustering support based on available CPU cores and environment settings
- Integrate PostHog analytics for API request and server metrics tracking
- Implement rate limiting with IP validation and bounded in-memory storage
- Enhance VercelRequest and VercelResponse interfaces with robust parsing and security headers
- Improve CORS handling with origin allowlists and credential support
- Validate and sanitize API endpoint paths to prevent directory traversal attacks
- Add request body size limit and enforce request timeout handling
- Provide structured logging for requests, responses, errors, and server lifecycle events
- Add health endpoint with uptime, metrics, environment, and version info
- Support graceful shutdown with analytics capture on termination signals
- Update create-checkout-session API with stricter CORS origin checks and OPTIONS method handling
- Refine hono-polar API subscription syncing with date object conversions and improved checkout flow
- Enhance secret-chat API error handling with detailed status codes and messages
- Update service worker cache revision for production deployment
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
High Priority Fixes:
- Replace vulnerable regex patterns in IP validation with safe string operations
- Secure cookie parsing with Object.create(null) to prevent prototype pollution
- Enhanced file system operations with additional validation layers
- Add PostHog analytics payload size limits (32KB) and comprehensive PII sanitization
- Implement error message sanitization to prevent information leakage

Security Improvements:
- Safe IPv4/IPv6 validation without regex DoS vulnerability
- Cookie name/value validation with length limits and safe patterns
- Multi-layer path traversal protection for API endpoint resolution
- PII pattern detection and redaction for analytics
- Development vs production error handling with safe messaging
- ESLint security rule compliance with appropriate exemptions for validated cases

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ration limits

- Updated regex patterns for sanitizing metadata, navigation, images, stylesheets, scripts, fonts, and meta tags to prevent potential vulnerabilities.
- Implemented iteration limits to avoid catastrophic backtracking in regex operations.
- Added validation checks for extracted URLs and text to ensure safety and compliance with length restrictions.

This commit addresses security concerns and improves the robustness of HTML content extraction.
- Resolved CORS configuration conflict in api-dev-server.ts using secure whitelist approach
- Resolved git provider detection conflict in lib/deployment/netlify.ts using comprehensive URL parsing
- Fixed regex escape character issue in netlify.ts for security compliance

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
**HIGH RISK - CORS Misconfiguration Fixed:**
- Separate trusted origins from allowed origins in api-dev-server.ts
- Only enable credentials for explicitly trusted domains
- Prevent credential hijacking via dynamic origin setting

**MEDIUM RISK - URL Validation Bypass Fixed:**
- Replace vulnerable substring matching with secure hostname validation
- Use proper URL parsing to prevent domain spoofing attacks
- Affected files: netlify.ts and vercel.ts deployment services

**MEDIUM RISK - Information Exposure Prevention:**
- Enhanced error sanitization in both development and production modes
- Remove ALL sensitive paths, environment variables, credentials from error messages
- Stricter character limits and complete information sanitization

Security improvements protect against:
- Credential theft via CORS misconfiguration
- Domain spoofing attacks (evil.com/github.com bypasses)
- Internal system information disclosure through error messages

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix Promise being passed to Convex in EnhancedChatInterface.tsx by properly consuming textStream
- Fix 404 error on tRPC billing endpoint by correcting URL path to /hono/trpc/
- Add robust array checks to prevent Se.map undefined errors
- Improve metadata handling with proper values instead of undefined
- Enhanced error handling and logging for tRPC requests

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Take the more secure origin validation from main branch that includes
additional isValidOrigin checks for both trusted and allowed origins.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace `existsSync` with `statSync` for safer file existence checks in API endpoints.
- Improve error handling for non-file responses and inaccessible directories.
- Update CORS handling in `create-checkout-session` to validate origins more robustly.
- Introduce helper functions for validating environment variables in `hono-polar` API.
- Refactor input sanitization and validation logic in various components for enhanced security.
- Clean up unused imports and optimize component structures across multiple files.
- Update analytics configuration to enable based on the presence of the PostHog API key.
- Improve IP hashing method for better privacy using SHA-256.
- Refine IP validation logic with comprehensive regex for IPv6 support.
- Enhance error responses in API endpoints to include decoded endpoint information.
- Implement structured logging for API requests and errors, ensuring sensitive data is scrubbed.
- Update README to reflect enhanced security features and request timeout settings.
- Add new environment variables for Sentry error monitoring and privacy consent management.
- Optimize dependency versions in package.json and bun.lock for improved stability.
- Simplified regex patterns for email and phone number validation.
- Improved handling of sensitive headers in the scrubHeaders function.
- Updated error sanitization methods to prevent sensitive data leaks.
- Enhanced URL validation patterns for GitHub links.
- Refined object sanitization to prevent prototype pollution and ensure safe handling of sensitive fields.
…for credentials transfer

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
- Resolved IP validation function conflicts by choosing the newer, more robust implementation
- Resolved cookie parsing conflicts by keeping enhanced prototype pollution protection
- Resolved file existence check conflicts by using the safer validation approach
- Resolved HTML sanitization conflicts by keeping the sanitize-html library approach
- All conflicts resolved while maintaining security best practices

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…m our branch

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ranch

Merged security enhancements while preserving functionality:

- Enhanced error sanitization with comprehensive path and credential redaction
- Improved CORS handling with secure credential-only for trusted origins
- Upgraded IP hashing from base64 to SHA-256 for better anonymization
- Tightened error message length limits and expanded error pattern matching
- More comprehensive PII detection and sanitization patterns
- Regenerated bun.lock to resolve dependency conflicts

All security improvements from dev-branch have been prioritized while
maintaining existing functionality from qoder branch.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Introduced `ZapdevDeploymentSecrets` to handle sensitive deployment tokens securely.
- Updated `ZapdevDeploymentConfig` to exclude sensitive access tokens, ensuring they are retrieved at runtime.
- Enhanced deployment manager to utilize the new secrets structure for Netlify and Vercel services.
- Improved error handling and logging in various API endpoints for better security and maintainability.
- Updated README to reflect changes in deployment configuration and security practices.
…pdate service worker registration

- Removed commented-out critical CSS resources for clarity.
- Added module preload link for improved loading performance of main module.
- Updated service worker registration to use a more generic '/sw.js' path for better maintainability.
Resolved merge conflicts prioritizing security improvements and maintaining functionality:

- API-SERVER-README.md: Fixed malformed line in graceful shutdown feature
- api/deploy.ts: Used main branch approach with runtime secrets validation
- api/domains.ts: Kept deployment manager configuration comment from main
- api/success.ts: Maintained strict authentication requirements from qoder
- lib/deployment/types.ts: Used main branch configuration comment
- lib/deployment/vercel.ts: Kept enhanced extractRepoPath with security improvements
- src/components/PrivacyConsentBanner.tsx: Used function declaration style from main
- src/components/SubscriptionUpgradeModal.tsx: Removed SafeText dependency
- src/components/auth/EnhancedSignUp.tsx: Kept clean interface without unused onComplete prop
- src/components/auth/PrivacyAwareSignInButton.tsx: Used function declaration style
- src/main.tsx: Removed unused imports from qoder branch
- src/utils/security.ts: Kept simpler script tag regex pattern from qoder
- src/utils/text-sanitizer.ts: Preserved Zod validation enhancements from qoder

All conflicts resolved while maintaining security improvements and code quality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix TypeScript errors in API files (type assertions, unused parameters)
- Update AI SDK usage from v2 to v3 (maxTokens → maxCompletionTokens)
- Fix tRPC context function signature for Hono adapter
- Resolve duplicate interface declarations in deployment types
- Add missing required properties to analytics events
- Fix Vite PWA plugin Cache-Control header configuration
- Remove invalid regex pattern in workbox cacheableResponse config

All TypeScript build errors resolved. Vercel deployment now succeeds.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Aug 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
zapdev Error Error Aug 26, 2025 7:26am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a redundant authentication check block in api/success.ts, introduces navigation to the pricing page in EnhancedChatInterface’s upgrade flow, and applies a whitespace-only change in vite.config.ts. No exported/public signatures are changed.

Changes

Cohort / File(s) Summary
API Endpoint: auth check duplication
api/success.ts
Adds a second, nested extraction/validation of the Authorization header inside try, duplicating the “Require authentication” logic; functional flow otherwise unchanged (verifyAuth, subscription fetch, error handling).
UI Component: upgrade navigation
src/components/EnhancedChatInterface.tsx
Integrates React Router’s useNavigate; routes to /pricing during the upgrade action. No API surface changes.
Build Config: formatting
vite.config.ts
Inserts a blank line within runtimeCaching.cacheableResponse; no behavioral change.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant H as /api/success Handler
  participant A as Auth Service
  participant S as Subscription Store

  C->>H: HTTP request with Authorization
  rect rgba(230,240,255,0.6)
    note over H: Initial auth check
    H->>H: Extract auth header
    H->>A: verifyAuth(token)
    A-->>H: Auth OK / Error
  end

  rect rgba(255,240,230,0.6)
    note over H: Nested duplicate auth check
    H->>H: Re-extract auth header
    H->>A: verifyAuth(token) (again)
    A-->>H: Auth OK / Error
  end

  H->>S: Fetch subscription
  S-->>H: Subscription data
  H-->>C: Response
Loading
sequenceDiagram
  autonumber
  participant U as User
  participant E as EnhancedChatInterface
  participant R as React Router

  U->>E: Click "Upgrade"
  E->>R: navigate("/pricing")
  R-->>U: Route to Pricing page
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A hop, a skip, to Pricing I dash,
Two auth checks twinned—what a splash!
Vite takes a breath, a whitespace sigh,
Buttons blink, and routes fly by.
I thump my paw: “Ship it quick!”
Carrots cached, features slick. 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8ee7be5 and 8cb3bda.

📒 Files selected for processing (3)
  • api/success.ts (1 hunks)
  • src/components/EnhancedChatInterface.tsx (1 hunks)
  • vite.config.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gitguardian
Copy link

gitguardian bot commented Aug 26, 2025

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
20372498 Triggered Generic High Entropy Secret 72993ac .env.deployment.template View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@claude
Copy link

claude bot commented Aug 26, 2025

Claude finished @otdoges's task —— View job


Pull Request Review

Todo List:

  • Review changed files for code quality and best practices
  • Investigate GitGuardian security alert
  • Check performance implications
  • Assess test coverage needs
  • Provide comprehensive feedback

🔍 Review Summary

Security Issues ⚠️

  1. GitGuardian Alert - FALSE POSITIVE: The security alert is for the template file .env.deployment.template which contains example placeholders like phc_your_posthog_project_key. This is a template file with example values, not actual secrets.

  2. Linting Security Issues 🚨:

    • api-dev-server.ts:140 - Generic Object Injection Sink
    • api-dev-server.ts:235 - Unsafe Regular Expression
    • src/lib/github-service.ts:132-133 - Unsafe Regular Expressions

Code Quality Issues

Critical Build Error 🔥

  • vite.config.ts:86 - Invalid Workbox configuration causing build failure:
    headers: {
      'Cache-Control': /^(?!.*no-store).*/,  // ❌ Should be string, not regex
    }

api/success.ts - Code Duplication

// Lines 20-23 (DUPLICATE)
const rawAuthHeader = Array.isArray(req.headers['authorization'])
  ? req.headers['authorization'][0]
  : req.headers['authorization'];
const authorization = typeof rawAuthHeader === 'string' ? rawAuthHeader : undefined;

// Lines 28-32 (DUPLICATE) 
const rawAuthHeader = Array.isArray(req.headers['authorization'])
  ? req.headers['authorization'][0] 
  : req.headers['authorization'];
const authorization = typeof rawAuthHeader === 'string' ? rawAuthHeader : undefined;

Performance Assessment

  • EnhancedChatInterface.tsx: Well-optimized with memoization, callbacks, and proper React patterns
  • vite.config.ts: Good bundle splitting configuration (when build works)

Test Coverage ⚠️

  • No test files modified or added in this PR
  • Existing security vulnerabilities suggest insufficient testing of edge cases

🎯 Recommendations

Must Fix (Blocking):

  1. Fix PWA configuration in vite.config.ts:86:

    headers: {
      'Cache-Control': 'no-store',  // Use string instead of regex
    }
  2. Remove duplicate auth code in api/success.ts (lines 28-32)

Should Fix (Security):

  1. Address unsafe regex patterns in security-sensitive files
  2. Fix object injection sink in api-dev-server.ts:140

Code Quality:

  1. Remove unused variables flagged by TypeScript ESLint
  2. Add proper TypeScript types instead of any

✅ What's Good

  • Comprehensive security measures in EnhancedChatInterface.tsx
  • Input validation and sanitization properly implemented
  • Error handling with fallback messages
  • Proper authentication patterns (despite duplication)

🚦 Verdict

❌ NEEDS WORK - This PR has a critical build error and security issues that must be addressed before merging.

Priority: Fix the Workbox configuration first to unblock builds, then address security vulnerabilities.

@dogesman098 dogesman098 merged commit 18ab19d into main Aug 26, 2025
6 of 8 checks passed
@dogesman098 dogesman098 deleted the dev branch August 26, 2025 07:25
@cursor
Copy link

cursor bot commented Aug 26, 2025

Bugbot found 3 bugs

To see them, activate your membership in the Cursor dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments